package org.example.reverse;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import java.util.Date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
@Component(value = "dateReverse")
public class DateReverse implements Converter<String,Date> {
    @Override
    public Date convert(String source) {
        Date date = null;
        if (source==null || "".equals(source)){
            return date;
        }

        try {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            date = simpleDateFormat.parse(source);

        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
}
